From 224d655aba8423f8ca61cc397bf1ea647004e4c6 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Thu, 23 Feb 2006 11:31:01 +0100 Subject: [PATCH] Whenever the slice of a domU is set to 0, sedf_adjdom() sets extraweight to 0. Later, in desched_extra_dom(), if the extrawight is not set, the vcpu's score is calculated with this: /*domain was running in L1 extraq => score is inverse of utilization and is used somewhat incremental!*/ if ( !inf->extraweight ) /*NB: use fixed point arithmetic with 10 bits*/ inf->score[EXTRA_UTIL_Q] = (inf->period << 10) / inf->slice; Which can result in a divide by zero. This changeset adds a comments and additional sanity check to prevent this case from crashing Xen. Signed-off-by: Ryan Harper --- xen/common/sched_sedf.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/common/sched_sedf.c b/xen/common/sched_sedf.c index 45fdac3073..d7a68262b1 100644 --- a/xen/common/sched_sedf.c +++ b/xen/common/sched_sedf.c @@ -1609,15 +1609,19 @@ static int sedf_adjdom(struct domain *p, struct sched_adjdom_cmd *cmd) else { /*time driven domains*/ for_each_vcpu(p, v) { - /* sanity checking! */ - if(cmd->u.sedf.slice > cmd->u.sedf.period ) + /* + * Sanity checking: note that disabling extra weight requires + * that we set a non-zero slice. + */ + if ( (cmd->u.sedf.slice == 0) || + (cmd->u.sedf.slice > cmd->u.sedf.period) ) return -EINVAL; EDOM_INFO(v)->weight = 0; EDOM_INFO(v)->extraweight = 0; EDOM_INFO(v)->period_orig = - EDOM_INFO(v)->period = cmd->u.sedf.period; + EDOM_INFO(v)->period = cmd->u.sedf.period; EDOM_INFO(v)->slice_orig = - EDOM_INFO(v)->slice = cmd->u.sedf.slice; + EDOM_INFO(v)->slice = cmd->u.sedf.slice; } } if (sedf_adjust_weights(cmd)) -- 2.30.2